package com.atguigu.exer.threadex;/**
 * @Classname Thread01
 * @Description TODO
 * @Date 2021/6/15 16:54
 * @Created by GUOCHEN
 */

import lombok.SneakyThrows;

import java.util.concurrent.TimeUnit;

/**
 * @program: my-spring-completely
 * @description:
 * @author: GUOCHEN
 * @create: 2021/06/15 16:54
 */
public class Thread01 {
    //两个线程  一个打奇数
    //一个打偶数
    public static void main(String[] args) {
//        A a = new A();
//        a.start();
//        System.out.println("---------------------------------------");
//        B b = new B();
//        b.start();


        new Thread(() -> {
            for (int i = 0; i <10 ; i++) {
                if (i%2==0){
                    System.out.println(i+" o");

                }
            }
        }).start();

        new Thread(() -> {
            for (int i = 0; i <10 ; i++) {
                if (i%2!=0){
                    System.out.println(i+" o");
                    try {
                        Thread.sleep(0L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }

}


class A extends Thread{
    @Override
    public void  run (){
        for (int i = 0; i <10 ; i++) {
            if (i%2==0){
                System.out.println(i+" o");
            }
        }
    }
}


class B extends Thread{
    @Override
    public void  run (){
        for (int i = 0; i <10 ; i++) {
            if (i%2!=0){
                System.out.println(i+" j");
            }
        }
    }
}
